
'use strict';
const cloud = require('tcb-admin-node');
const tcbConfig = { env: 'meatom04dev-0g86uke14c3a060f' }; //当前环境 ENV_ID
const auth = cloud.init(tcbConfig).auth();
const db = cloud.database();

// 云函数入口函数
exports.main = async (event, context) => {
  let uid = event.uid
  // event
  return db.collection('User').where({
      uid : uid
    })
    .update({
      coin : event.coin,
      diamond : event.diamond,
      bagNum : event.bagNum,
      bag : event.bag,
      team : event.team,
      pass_list: event.pass_list,
      card: event.card,
      card_team : event.card_team,
      guideList:event.guideList,
      task:event.task,
      last_time: (new Date()).valueOf()
    })
    .then(
      res => {
        return {
          status : true,
          text : '更新成功'
        }
      }
    ).catch(
      err => {
        return {
          status : false,
          text : '更新失败'
        }
      }
    )
}
